package cn.sccdlg.ssm.utils;

import java.util.UUID;

/**
 * @author RaoShuang
 * @emil 991207823@qq.com
 * @date 2020/10/27 23:15
 * UUID工具类
 */
public final class UuidUtils {
    private UuidUtils() {
        throw new RuntimeException("UuidUtils.class can't be instantiated");
    }

    /**
     * 获取随机的uuid小写字符串
     */
    public static String getLittleRandomUuid() {
        UUID uuid = UUID.randomUUID();
        return uuid.toString();
    }

    /**
     * 获取随机的UUID大写字符串
     */
    public static String getRandomUuid() {
        UUID uuid = UUID.randomUUID();
        return uuid.toString().toUpperCase();
    }

    /**
     * 从UUID字符串中去除“-”分隔符
     */
    public static String removeSeparatorFromUuid(String uuid) {
        return uuid.replace("-", "");
    }

    /**
     * 生成小写32位UUID(即去除“-”分隔符)
     */
    public static String nonLineSmallLetters() {
        return getLittleRandomUuid().replace("-", "");
    }

    /**
     * 获取大写32位的UUID(即去除“-”分隔符)
     */
    public static String getUnid() {
        String uuid = getRandomUuid();
        return removeSeparatorFromUuid(uuid);
    }

    public static void main(String[] args) {
        String unid = getUnid();
        System.out.println(unid);
        unid = nonLineSmallLetters();
        System.out.println(unid);
    }
}
